<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Add a job server</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanworker.addoptions.html">GearmanWorker::addOptions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanworker.addservers.html">GearmanWorker::addServers</a></div>
 <div class="up"><a href="class.gearmanworker.html">GearmanWorker</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="gearmanworker.addserver" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">GearmanWorker::addServer</h1>
  <p class="verinfo">(PECL gearman &gt;= 0.5.0)</p><p class="refpurpose"><span class="refname">GearmanWorker::addServer</span> &mdash; <span class="dc-title">Add a job server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-gearmanworker.addserver-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>GearmanWorker::addServer</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code><span class="initializer"> = 127.0.0.1</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 4730</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Adds a job server to this worker.  This goes into a list of servers than can be used to run jobs.
   No socket I/O happens here.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-gearmanworker.addserver-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">host</code></em></dt>

     <dd>

      <p class="para">
       任务服务器主机名。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">port</code></em></dt>

     <dd>

      <p class="para">
       任务服务器端口号。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-gearmanworker.addserver-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-gearmanworker.addserver-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4236">
    <p><strong>Example #1 Add alternate Gearman servers</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$worker</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">GearmanWorker</span><span style="color: #007700">();&nbsp;<br /></span><span style="color: #0000BB">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"10.0.0.1"</span><span style="color: #007700">);&nbsp;<br /></span><span style="color: #0000BB">$worker</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"10.0.0.2"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7003</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-gearmanworker.addserver-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="gearmanworker.addservers.html" class="methodname" rel="rdfs-seeAlso">GearmanWorker::addServers()</a> - Add job servers</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanworker.addoptions.html">GearmanWorker::addOptions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanworker.addservers.html">GearmanWorker::addServers</a></div>
 <div class="up"><a href="class.gearmanworker.html">GearmanWorker</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
